﻿using Architecture.API.Application.TraceabilityCommand.DeepProcessingCommand;
using MediatR;
using Traceability.Domain.DeepProcessingDomain;
using Traceability.Domain.Service.DeepProcessingServices;

namespace Architecture.API.Application.TraceabilityCommandHandler.DeepProcessingCommandHandler
{
    /// <summary>
    /// 修改
    /// </summary>
    public class UpdateDeepProcessingCommandHandler : IRequestHandler<UpdateDeepProcessingCommand, int>
    {
        /// <summary>
        /// 深加工服务
        /// </summary>
        protected readonly IDeepProcessingService deepProcessingService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="deepProcessingService">深加工服务</param>
        public UpdateDeepProcessingCommandHandler(IDeepProcessingService deepProcessingService)
        {
            this.deepProcessingService = deepProcessingService;
        }

        /// <summary>
        /// 修改深加工信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<int> Handle(UpdateDeepProcessingCommand request, CancellationToken cancellationToken)
        {
            return await deepProcessingService.UpdateDeepProcessing(new DeepProcessing() { DeepProcessingId=request.DeepProcessingId, TeamsAndGroups = request.TeamsAndGroups, PersonInCharge = request.PersonInCharge, UpdatedBy = request.UpdatedBy });
        }
    }
}
